package org.example
import org.apache.spark.rdd.RDD
import org.apache.spark.sql.{DataFrame,SparkSession}

object sparkData2_SQL1 {
  def main(args: Array[String]): Unit = {
    val spark = SparkSession
      .builder()
      .master("local[*]")
      .getOrCreate()
    val sc = spark.sparkContext
    val student1:RDD[String] = sc.textFile("src/main/resources/student.txt")
    student1.foreach(println)
    val studentFrame:DataFrame=
      spark.read.csv("src/main/resources/student.txt")
    studentFrame.printSchema()
    studentFrame.show()
    studentFrame.createTempView("score")
    val data2: DataFrame = spark.read
      .option("encoding","GBK")
      .option("header","true")
      .csv("src/main/resources/23data2.csv")
    data2.printSchema()
    data2.show(60)
    sc.stop()
  }

}
